﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace TextEditorDP
{
    public class CPanel :Panel, Widget
    {
        protected HelpHandler _successor;
        protected string _topic;

        public CPanel()
            : base()
        {
        }

        public virtual bool HasHelp()
        {
            if (_topic == "")
                return false;
            return true;
        }

        public virtual void SetHandler(HelpHandler successor, string topic)
        {
            _successor = successor;
            _topic = topic;
        }

        public virtual void HandleHelp()
        {
            if (HasHelp())
            {
                MessageBox.Show(_topic);
            }
            else
            {
                if (_successor != null)
                {
                    _successor.HandleHelp();
                }
            }
        }
    }
}
